// 加性操作符
console.log('加性操作符++++++++++++++++++++++++++++++++++')
var number1 = 5
var number2 = 2
var number3 = '5'
var str1 = '1234abc'
var str2 = 'hello'
var obj = {
  valueOf: function () {
    // 此值转化不了字符串，会基于返回的值，继续调用toString方法，而不是对象中的toString
    return false
  }
}
var boolean = true
console.log(number1 + number2) // 7
console.log(number1 + number3) // 55
console.log(number3 + number3) // 55
console.log(3 + 3 + '3') // 63
console.log(3 + '3' + 3) // 333
console.log(number1 + null) // 5
console.log(true + null) // 1
console.log(str1 + str2) // 1234abchello
console.log(obj + number3) // false5
console.log(null + number3) // null5
console.log(undefined + number3) // undefined5
console.log('5 + 2 = ' + (number1 + number2)) // 5 + 2 = 7
console.log('5 + 2 = ' + number1 + number2) // 5 + 2 = 52

console.log(5 - true) // 4
console.log(5 - undefined) // NaN 因为undefined不可以被Number转化
console.log('5' - '4') // 1 4和5都转化成了数字
console.log(5 - '123asd') // NaN
console.log(5 - '') // 5
console.log(5 - null) // 5
console.log(NaN - 1) // NaN
console.log(null - true) // -1
console.log('关系操作符++++++++++++++++++++++++++++++++++++++++++++')
console.log('数值与Bollean做比较', 3 > true) // true 将布尔值转化成了数字
var obj = {
  valueOf: function () {
    return 1
  }
}
console.log('数值与对象的比较', 3 > obj) // true
console.log('布尔值与对象的比较', false < obj) // true 两边全部转化为数字
console.log(3 > 5) // false
console.log(3 > '24') // false  将24转化为了数字再进行比较，所以结果是False
console.log('3' > '24') // true 因为字符串的比较，是比较从左到右的字符编码
console.log('a' > 3) //false a无法转化为数字，因此被转成了NaN,NaN做比较任何运算的结果都是false
console.log(true > false) // true 比较双方全部转化为数字去比较
console.log([1, 2, 3] > 0) // false 因为数组转化为数字是NaN,任何比较运算的结果都是false
console.log(null < obj) // true
console.log(Number([1, 2, 3]))
console.log('相等操作符+++++++++++++++++++++++++++++++++++++++++++++++++++')
console.log(true == 1) // true
console.log('55' == 55) // true
console.log(obj == '1') // true
console.log(null == undefined) // true
console.log(null === undefined) // false
console.log('逗号操作符+++++++++++++++++++++++++++++++++++++++++++++++++++++')
var num = (0, 1, 2)
console.log('num', num) // 2